//
//  AddTableViewCell.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/3.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "AddTableViewCell.h"

@implementation AddTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.backgroundColor = [UIColor clearColor];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    self.chineseLabel = [UILabel new];
    
    self.chineseLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15 * SCREENH6];
    self.chineseLabel.textColor = ColorWithRGB(0xffffff);
    self.chineseLabel.textAlignment = NSTextAlignmentLeft;
    
    [self addSubview:self.chineseLabel];
    
    [self.chineseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
        make.top.mas_equalTo(self).offset(22 * SCREENH6);
    }];
    
    
    self.englishLabel = [UILabel new];
    
    self.englishLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16 * SCREENH6];
    self.englishLabel.textColor = ColorWithRGB(0xbebebe);
    self.englishLabel.textAlignment = NSTextAlignmentLeft;
    
    [self addSubview:self.englishLabel];
    
    [self.englishLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
        make.top.mas_equalTo(self.chineseLabel.mas_bottom);
//        make.centerY.mas_equalTo(self);
    }];
    
    
    self.showImage = [UIImageView new];
    
    self.showImage.contentMode = UIViewContentModeScaleAspectFit;
    
    [self addSubview:self.showImage];
    
    [self.showImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self).offset(-15 * SCREENH6);
        make.centerY.mas_equalTo(self);
        make.width.mas_equalTo(22 * SCREENH6);
        make.height.mas_equalTo(22 * SCREENH6);
    }];
    
    self.lineView = [UIView new];
    
    self.lineView.backgroundColor = [UIColor whiteColor];
    self.lineView.alpha = 0.1;
    
    [self addSubview:self.lineView];
    
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.mas_equalTo(self);
        make.height.mas_equalTo(1 * SCREENH6);
    }];
    
}


- (void)setModel:(AddOptional *)model{
    
    _model = model;
    
    self.englishLabel.text = model.symbolName;
    self.chineseLabel.text = model.ch_name;
    
    NSString * ishas = [NSString stringWithFormat:@"%@",model.isHas];
    
    if ([ishas isEqualToString:@"0"]) {
        
        self.showImage.image = [UIImage imageNamed:@"添加"];
    }else{
        
        self.showImage.image = [UIImage imageNamed:@"对勾"];
    }
    
}


- (void)setSearchModel:(AddSearchModel *)searchModel{
    
    _searchModel = searchModel;
    
    self.englishLabel.text = searchModel.symbolName;
    self.chineseLabel.text = searchModel.ch_name;
    
    NSString * ishas = [NSString stringWithFormat:@"%@",searchModel.isHas];
    
    if ([ishas isEqualToString:@"0"]) {
        
        self.showImage.image = [UIImage imageNamed:@"添加"];
    }else{
        
        self.showImage.image = [UIImage imageNamed:@"对勾"];
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
